package com.xjh.t.vo;

import cn.hutool.json.JSONObject;
import com.xjh.t.domain.FileInfo;
import com.xjh.t.domain.GroupInfo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

@Data
@EqualsAndHashCode(callSuper = false)
public class FileInfoVo extends FileInfo {

    private static final long serialVersionUID = 1L;

    private Integer page=1;
    private Integer limit=50;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startTime;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date endTime;

    //创建者账号
    private String uploadUserAccount;

    private float dpi;

    private float picwidth;

    private float picheight;

    private float leftDeleteDays;

    private String suolueUrl;

    private String yulanUrl;

    public void parsePicInfo()
    {
        try {
            JSONObject json = new JSONObject(this.getFeAttr());
            this.setDpi(json.getFloat("dpi"));
            this.setPicwidth(json.getFloat("width")/this.getDpi() * 2.54f);
            this.setPicheight(json.getFloat("height")/this.getDpi() * 2.54f);
            this.setSuolueUrl("http://small-thumbnail-image.oss-cn-hangzhou.aliyuncs.com/" + this.getFeId() + ".jpg");
            this.setYulanUrl("http://large-thumbnail-image.oss-cn-hangzhou.aliyuncs.com/" + this.getFeId() + ".jpg");


        }
        catch (Exception e)
        {

        }

    }
}
